package top.hkyzf.study.leetcode.dp;

import org.junit.Test;

/**
 * @author 朱峰
 * @date 2022-1-30 16:56
 */
public class 爬楼梯_70 {
    public int climbStairs1(int n) {
        if (n == 1) {
            return 1;
        }
        if (n == 2) {
            return 2;
        }
        return climbStairs(n-1) + climbStairs(n-2);
    }

    public int climbStairs(int n) {
        int pre = 0;
        int next = 1;
        int result = 0;
        for (int i = 1; i <= n; i++) {
            result = pre + next;
            pre = next;
            next = result;
        }
        return result;
    }

    @Test
    public void testClimbStairs () {
        int n = 7;
        System.out.println(climbStairs(n));
    }
}
